package org.ktx.osr.audio

import android.content.Context
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner
import java.io.File
import kotlin.test.assertNotNull
import kotlin.test.assertTrue

/**
 * MediaMerger的单元测试
 */
@RunWith(MockitoJUnitRunner::class)
class MediaMergerTest {

    @Mock
    private lateinit var mockContext: Context

    @Test
    fun testMediaMergerCreation() {
        val mediaMerger = MediaMerger(mockContext)
        assertNotNull(mediaMerger, "MediaMerger should be created successfully")
    }

    @Test
    fun testCleanupTempFiles() {
        val mediaMerger = MediaMerger(mockContext)
        
        // 创建临时文件进行测试
        val tempFile1 = File.createTempFile("test1", ".tmp")
        val tempFile2 = File.createTempFile("test2", ".tmp")
        
        // 确保文件存在
        assertTrue(tempFile1.exists(), "Temp file 1 should exist")
        assertTrue(tempFile2.exists(), "Temp file 2 should exist")
        
        // 清理文件
        mediaMerger.cleanupTempFiles(tempFile1, tempFile2)
        
        // 验证文件已被删除
        assertTrue(!tempFile1.exists(), "Temp file 1 should be deleted")
        assertTrue(!tempFile2.exists(), "Temp file 2 should be deleted")
    }
}
